﻿using Newtonsoft.Json;
using TradeDataAPI.Core.CacheManager;
using TradeDataAPI.Core.Extensions.AutofacManager;

namespace TradeDataAPI.Core.Common
{
    public class TokenInfo
    {
        public string okta_account { get; set; }
        public string ChName { get; set; }
        public string EnName { get; set; }
    }


    public class GetTokenInfo
    {

        public static ICacheService CacheContext
        {
            get
            {
                return AutofacContainerModule.GetService<ICacheService>();
            }
        }

        /// <summary>
        /// 根据工号获取token缓存中的人员信息
        /// </summary>
        /// <param name="NumberWork"></param>
        /// <returns></returns>
        public static TokenInfo GetTokenUserInfoByNumberWork(string NumberWork)
        {
            var UserInfo = new TokenInfo();
            if (CacheContext.Exists(NumberWork))
            {
                var json = CacheContext.Get(NumberWork);
                UserInfo = JsonConvert.DeserializeObject<TokenInfo>(json);

                return UserInfo;
            }
            return null;
        }

    }





}
